
#include <stdio.h>
#include <string.h>

#define ENCODE_PATH	"../encode_html/"
#define TMP_FILE	"tmp_file"
#define MAX_LEN		1024 * 1024
#define SIZE_T		1

int main ( int argc,char *argv[])
{
	FILE *F, *C;
	char tmp1[MAX_LEN] = {0};
	//char name[MAX_LEN] = {0};
	int i = 0;

	F = fopen(argv[1], "rb");
	
	//strcpy(name,ENCODE_PATH);
	//strcat(name,argv[1]);

	C = fopen(TMP_FILE,"wb");
	if (!F || !C)
	{
		printf("Read or Write File Error!\n");
		return 1;
	}
	
	fread(tmp1,SIZE_T,MAX_LEN,F);
	for (i = 0; i < strlen(tmp1); i ++)
	{
		tmp1[i] = tmp1[i] - 1;
	}

	fwrite(tmp1,SIZE_T,strlen(tmp1),C);
	/*while(fgets(tmp1, sizeof(tmp1)-1, F) != NULL)
	{
		fwrite(tmp1,1,strlen(tmp1),C);
	}*/
	
	fclose(F);
	fclose(C);
	
	if (rename(TMP_FILE, argv[1]))
		return 1;
	
	return 0;
}

